<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var script_did_run, script, x;

test(() => {
  script_did_run = false;
  script = document.createElement('script');
  script.type = '0';  // This prevents execution on insertion.
  script.textContent = 'script_did_run = true; script.appendChild(x);';
  document.documentElement.appendChild(script);

  x = document.createElement('x');
  script.appendChild(x);
  script.type = '';   // This enables, but does not trigger, execution.
  assert_false(script_did_run, 'setting type should not trigger execution');

  var iframe = document.createElement('iframe');
  document.documentElement.appendChild(iframe);
  iframe.contentDocument.adoptNode(x);
  assert_false(script_did_run, 'removing child should not trigger execution');
  assert_equals(x.ownerDocument, iframe.contentDocument,
                'the element should have been adopted by the frame document');
});
</script>
